#ifndef SERIAL_COM_H
#define SERIAL_COM_H

#include <QObject>
#include <QTimer>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "QTimer"
#include "debugdevice.h"
#include <QThread>

#define CommedInterval  500

class Serial_com : public QThread
{
    Q_OBJECT
public:
    explicit Serial_com(QObject *parent = 0);
    ~Serial_com();

    QSerialPort *myCom;
    DebugDevice *deD;

signals:
    QByteArray data_src(QByteArray data);
    void Send_id(qint16);
    void Send_gps(QList<QByteArray>);
    void Send_key(qint16);
    void Read_Com(QString data_str);

public slots:
    void com_init(QString portName);
    void ComClose();
    void writeMyCom(QByteArray buf);
    void AddSendCommedList(QByteArray buf);
    void MainClose();

private slots:
    void Com_flush();
    void readMyCom();
    void Read_com_date(QByteArray dat);
    void portChange();
    void portError(QSerialPort::SerialPortError error);

private:
    QByteArray Read_Data;
    bool ok;
    QTimer *port_time;
    QList<QByteArray>date_list;
    QString usbName;

    QList<QByteArray> CommedList;

    QTimer *CommedTimer;
};

#endif // SERIAL_COM_H
